<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<script type="text/javascript">

    $(function () {
        $("#labApplyTable").treeTable();
    })

    function page(n,s){
        $("#pageNo").val(n);
        $("#pageSize").val(s);
        $("#labApplyForm").submit();
        return false;
    }
    function printPresc(labId,visitId,patientId){
        printPdf('${ctx}/lab/labApply/printPresc', 'labId='+labId +'&visitId='+visitId+'&patientId='+patientId);

    }
    //检验查看
    function labResult(url){
        layerIndex =layer.open({
            type: 2,
            title:'检验单查看',
            area: ['60%', '50%'],
            fixed: false, //不固定
            maxmin: true,
            content: url,
            btn: ['关闭'],
            yes:function(index,layero){
                layer.close(index);
            }
        });
    }
</script>
<div class="wrapper no-p" style="background-color: white">
    <div class="table-responsive no-border">
        <%--检验申请table--%>
        <div class="datatable-top">
            <div class="pull-left">
                <form:form hidden="hidden" id="labApplyForm" modelAttribute="labApply"
                           onsubmit="return loadDivForm('rightDiv','labApplyForm','${ctx}/lab/labApply/queryByCondition');"
                           method="post" class="form-inline">
                    <form:hidden path="patientId"/>
                    <form:hidden path="visitId" />
                    <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
                    <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
                    <%--<label>检验项目 ：</label>--%>
                    <%--<form:input path="itemName" htmlEscape="false" maxlength="50"--%>
                    <%--class="form-control"/> &nbsp;--%>
                    <input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>
                </form:form>
            </div>
        </div>
        <table id="labApplyTable" class="table table-bordered mg-t datatable">
            <thead>
            <tr>
                <%--<th style="width: 5%"><input type=checkbox id="examItemId"></th>--%>
                <th>申请时间</th>
                <th>申请单号</th>
                <th>执行科室</th>
                <th>标本</th>
                <th>确认状态</th>
                <th>操作
            </tr>
            </thead>
            <tbody>
            <c:forEach items="${page.list}" var="labApply" varStatus="lab">
                <tr id="${labApply.id}">
                    <td><fmt:formatDate value="${labApply.createDate}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
                    <td> ${labApply.applyOn}</td>
                    <td> ${labApply.implementDeptEt.deptName}</td>
                    <td> ${fns:getDictLabels(labApply.specimen,'SPECIMAN_DICT','')}</td>
                    <td> ${fns:getDictLabels(labApply.confirmFlag,'CONFIRM_DICT','')}</td>
                    <td>
                        <c:if test="${labApply.confirmFlag eq 1}">
                            <a href="#" class="btn btn-warning btn-xs"
                               onclick="labResult('${ctx}/doctor/lab/labResult/index?testNo=${labApply.applyOn}')">检验查看</a>
                        </c:if>
                        <c:if test="${labApply.chargeFlag=='0'}">
                            <a href="#" class="applyBt btn btn-danger btn-xs"
                               onclick="confirmExtend('确认要删除该检验吗？',function(){delLoad('rightDiv','${ctx}/lab/labApply/delete?id=${labApply.id}','${ctx}/lab/labApply/queryByCondition?visitId=${labApply.visitId}&patientId=${labApply.patientId}&inoroutFlag=1')})">删除</a>
                            <a href="#"
                               class="btn btn-warning btn-xs"
                               onclick="printPresc('${labApply.id}','${labApply.visitId}','${labApply.patientId}')">打印</a>
                        </c:if>
                        <c:if test="${labApply.confirmFlag eq 1 && labApply.chargeFlag eq 1}">
                            <a href="#" class="applyBt btn btn-danger btn-xs"
                               onclick="confirmExtend('确定要申请退费吗？',function(){delLoad('rightDiv','${ctx}/lab/labApply/outpRetCharge?id=${labApply.id}',
                                       '${ctx}/lab/labApply/queryByCondition?visitId=${labApply.visitId}&patientId=${labApply.patientId}&inoroutFlag=1')})">申请退费</a>
                        </c:if>
                        <c:if test="${labApply.chargeFlag eq 5}">
                            ${fns:getDictLabels(labApply.chargeFlag,'NO_CHARGE','')}
                        </c:if>
                        <c:if test="${labApply.chargeFlag eq 2}">
                            ${fns:getDictLabels(labApply.chargeFlag,'NO_CHARGE','')}
                        </c:if>
                    </td>
                </tr>
                <c:if test="${labApply.labItemList.size()>0}">
                    <tr id="${lab.count}" pid="${labApply.id}">
                        <td colspan="5">
                            <table class="table table-bordered mg-t">
                                <tr>
                                    <th>检查项目</th>
                                    <th>价格</th>
                                </tr>
                                <c:forEach items="${labApply.labItemList}" var="labItem" varStatus="ss">
                                    <tr>
                                        <td>${labItem.itemName}</td>
                                        <td>${labItem.costs}</td>
                                    </tr>
                                </c:forEach>
                            </table>
                        </td>
                    </tr>
                </c:if>
            </c:forEach>
            </tbody>
        </table>
        <div class="pagination">${page}</div>
    </div>
</div>

